//
//  ChatMessagesDataBase.h
//  AAIM
//
//  Created by awh on 2019/12/23.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@class BTMessageModel;

@interface ChatMessagesDataBase : NSObject

+ (instancetype)shareChatMessagesDataBase;

- (void)creatChatTable;

- (void)insertMessage:(BTMessageModel *)msg;

// 批量插入数据
- (void)insertMessagArray:(NSArray<BTMessageModel *> *)messages;

// 根据s时间戳修改消息的发送状态
- (void)updateMessage:(BTMessageModel *)msg statusTo:(MessageStatus)status;

// 根据时间戳删除聊天记录
- (void)deleteMessage:(BTMessageModel *)msg;

// 根据uid清空聊天记录
- (void)clearAllMessagesWithUid:(NSInteger)uid;

// 清除时间戳之前的聊天记录
- (void)deleteMessageBeforeTimestamp:(long long)timestamp;

// 根据uid更新头像
- (void)updateAvatarWithUid:(NSInteger)uid avatar:(NSString *)avatar;

// 根据uid更新昵称
- (void)updateUsernameWithUid:(NSInteger)uid username:(NSString *)username;

// 清空与所有好友的聊天记录
- (void)clearAllMessagesWithAllFriends;

// 根据uid查询一条最新记录
- (BTMessageModel *)recentlyMessageWithUid:(NSInteger)uid;

// 根据uid查询所有聊天记录
- (NSArray<BTMessageModel *> *)queryAllMessagesWithUid:(NSInteger)uid;
//查询所有好友
- (NSArray<BTMessageModel *> *)queryFriendsMessagesWithKeyWord:(NSString *) keyWord;
// 分页加载，每页20条
- (NSArray *)queryMessagesWithUid:(NSInteger)uid toTimestamp:(long long)toTimestamp;

// 加载最新的count条数据
- (NSArray *)queryMessagesWithUid:(NSInteger)uid count:(NSInteger)count;

// 根据uid和聊天内容模糊搜索
- (NSArray<BTMessageModel *> *)queryMessagesWithUid:(NSInteger)uid byContent:(NSString *)content;


@end

NS_ASSUME_NONNULL_END
